home *** CD-ROM | disk | FTP | other *** search
/ Aminet 22 / Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso / Aminet / dev / e / amigae33a.lha / E_v3.3a / Src.lha / Src / Afc / Search_Example.e < prev    next >
Text File  |  1997-09-09  |  1KB  |  56 lines

  1. /*
  2. ** StringNode Example-4
  3. **
  4. ** add(), search() AND insert() methods.
  5. **
  6. ** (C)Copyright 1996/97 Amiga Foundation Classes
  7. **
  8. ** See: http://www.intercom.it/~fsoft/afc.html
  9. **
  10. **      FOR more info about AFC AND more modules
  11. */
  12.  
  13. MODULE 'afc/StringNode',    -> Our MAGIC MODULE
  14.        'afc/explain_exception'
  15.  
  16. PROC main() HANDLE
  17.   DEF n:PTR TO stringnode      -> This is our OBJECT instance
  18.  
  19.   NEW n.stringnode()           -> OBJECT initialization
  20.  
  21.   n.add('Zorro')              -> Here we add some items...
  22.   n.add('Batman')
  23.   n.add('Superman')
  24.   n.add('Gold Drake')
  25.   n.add('Mandrake')
  26.   n.add('MOMMY')
  27.  
  28.   shwall(n)                   -> Here we see them
  29.  
  30.   n.search('bat#?')           -> The search is CASE insensitive AND match the first one ;)
  31.                               -> Note we use STANDARD AmigaDOS match pattern strings!
  32.  
  33.   WriteF('Current:\s\n', n.obj()) -> Here we are!
  34.  
  35.   n.insert('Spiderman')       -> Wow! Another super-hero after Batman!
  36.   shwall(n)
  37.  
  38. EXCEPT DO
  39.   IF exception THEN WriteF('Exception: \z\h[8]\n', exception)
  40.   END n                       -> Remember ALWAYS TO end an OBJECT
  41.   CleanUp(0)
  42. ENDPROC
  43.  
  44. PROC shwall(n:PTR TO stringnode)
  45.   WriteF('------- \d ----------\n', n.numitems())
  46.  
  47.   IF n.first()                      -> Here we go TO the first node item
  48.     REPEAT
  49.       WriteF('Node:\s\n', n.obj()) -> Node STRING...
  50.     UNTIL n.succ() = FALSE          -> LOOP UNTIL the end
  51.   ELSE
  52.     WriteF('No Nodes in LIST...\n')
  53.   ENDIF
  54. ENDPROC
  55.  
  56.